package com.chentf.reggie.demo;

import java.util.Arrays;

public class Bubble {
    public static void main(String[] args) {
        int [] num = {199,33,55,66,999,777,888};  //静态化创建一组数组
        System.out.println("num排序前：[199,33,55,66,999,777,888]");
        int temp;    //为后续比较创建一个临时变量
        for (int i = 0 ;i<num.length;i++){     //进行排序
            for (int n = 0 ; n<num.length-1-i; n++){
                if (num[n]>num[n+1]){              //进行比较
                    temp = num[n];
                    num[n] = num[n+1];
                    num[n+1] = temp; }
            }
        }

        System.out.println("num排序后:"+Arrays.toString(num));

    }
}
